<template>
    <div>
        {{form}}
        <van-field label="用户名" placeholder="请输入用户名" v-model="form.mobile"/>
        <van-field label="密码" placeholder="请输入密码" v-model="form.password"/>
        <van-button @click="login">登录</van-button>
    </div>
</template>

<script>
import axios from '../../http/axios'
// import axios from 'axios'
    export default {
        data() {
            return {
                form:{},
                
                
            }
        },
        methods: {
             //登录
            login(){
                axios('/users/login/','post',this.form).then(res=>{
                    if(res.code == 200){
                        localStorage.setItem('userid',res.userid)
                        localStorage.setItem('name',res.name)
                        localStorage.setItem('mobile',res.mobile)
                        localStorage.setItem('token',res.token)
                        let page = res.pagelist
                        //拿过来是对象转换成字符串
                        if(page.length>0){
                            let pagelist = JSON.stringify(page)
                            localStorage.setItem('pagelist',pagelist)
                            
                        }
                        
                        
                        // this.$router.push('/com')
                    }
                })
            
            }
        },
    }
</script>

<style scoped>

</style>